Ext.ns('EasyExt.tool');

EasyExt.tool.SystemPrompt = Ext.extend(Ext.Window, {
    detailVisible: false,
    initComponent: function() {
        Ext.apply(this, {
            title: '系统提示',
            layout: 'border',
            width: 600,
            height: 300,
            resizable: false,
            modal: true,
            cls: 'system-prompt',
            items: [{
                region: 'north',
                height: 85,
                border: false,
                items: [{
	                xtype: 'box',
                    height: 65,
                    autoScroll: true,
	                cls: 'message',
	                html: this.message
	            }, {
	                xtype: 'box',
                    height: 20, 
	                html: '---------------------------------------------------详细信息-----------' 
	                      + '----------------------------------<div class="detail-button fold"></'
	                      + 'div>---------'
	            }]
            }, {
                region: 'center',
                xtype: 'panel',
                border: false,
                autoScroll: true,
                html: this.detail
            }],
            bbar: ['->', {
                text: '确定',
                handler: function() {
                    this.close();
                },
                scope: this
            }]
        });
        EasyExt.windows.SystemPrompt.superclass.initComponent.apply(this, arguments);
    },
    afterRender: function() {
        EasyExt.windows.SystemPrompt.superclass.afterRender.apply(this, arguments);
        this.getDetailButton().on('click', this.toggleDetailVisible, this);        
    },
    getDetailButton: function() {
        return this.rendered ? this.el.select('.detail-button').item(0) : null;
    },
    toggleDetailVisible: function() {    
        this.detailVisible = !this.detailVisible;
        var detailButton = this.getDetailButton();
        if (detailButton) {
	        detailButton.removeClass(this.detailVisible ? 'fold' : 'unfold');
	        detailButton.addClass(this.detailVisible ? 'unfold' : 'fold');
        }
        if (this.detailVisible)
            this.setHeight(375);          
        else
            this.setHeight(175); 
    }
});

EasyExt.tool.SystemPrompt.prompt = function(message, detail) {
    var sp = new EasyExt.tool.SystemPrompt({
        message: message,
        detail: detail
    });
    Ext.WindowMgr.bringToFront(sp);
    sp.show();
};

EasyExt.prompt = function(message, detail) {
    var sp = new EasyExt.tool.SystemPrompt({
        message: message,
        detail: detail
    });
    Ext.WindowMgr.bringToFront(sp);
    sp.show();	
};